<?php

namespace Biz\model\course;

use Doraemon\pockets\datebase\BaseDbModel;

class CourseLog extends BaseDbModel
{

    const _CONFIG_FILE_ = 'db_course';

    const _CONFIG_SELECT_ = 'db_course';

    const _DATABASE_ = 'hhz_course';

    const _TABLE_NAME = 'course_log';

    const OPERATE_TYPE_CREATE = 1;//创建课程
    const OPERATE_TYPE_EDIT = 2;//编辑课程
    const OPERATE_TYPE_ONLINE = 3;//上架课程
    const OPERATE_TYPE_OFFLINE = 4;//下架课程
    const OPERATE_TYPE_ADD_CHAPTER = 5;//添加章节
    const OPERATE_TYPE_EDIT_CHAPTER = 6;//编辑章节
    const OPERATE_TYPE_DEL_CHAPTER = 7;//删除章节

    public static function selectByWhere($where, $select = '*')
    {
        $list = self::select($select, $where);
        return $list;
    }

    public static function getByWhere($where)
    {
        return self::get('*', $where);
    }

    public static function selectCount($where)
    {
        return self::count($where);
    }

    public static function insertData($data)
    {
        $ret = self::insert($data);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return self::id();
    }

    public static function updateData($data, $where)
    {
        $ret = self::update($data, $where);
        if ($ret->errorCode() !== '00000') {
            return false;
        }
        return true;
    }

}

